﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

public partial class homepage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        binddata();
    }

    private void binddata()
    {
        IList<Promotion> promotionList = PromotionService.GetInstance().GetOrderedPromotionList();
        if (promotionList.Count < 2)
            return;

        title1.Text = promotionList[0].PromotionTitle;
        date1.Text = promotionList[0].StartDay.ToString("yyyy-MM-dd") + " - " + promotionList[0].DueDay.ToString("yyyy-MM-dd");
        bannerdiv1.Attributes["postPath"] = Page.ResolveUrl("~/pictures/promotion/" + promotionList[0].PictureBName);
        bannerimg1.Attributes["src"] = Page.ResolveUrl("~/pictures/promotion/" + promotionList[0].PictureAName);

        title2.Text = promotionList[1].PromotionTitle;
        date2.Text = promotionList[1].StartDay.ToString("yyyy-MM-dd") + " - " + promotionList[1].DueDay.ToString("yyyy-MM-dd");
        bannerdiv2.Attributes["postPath"] = Page.ResolveUrl("~/pictures/promotion/" + promotionList[1].PictureBName);
        bannerimg2.Attributes["src"] = Page.ResolveUrl("~/pictures/promotion/" + promotionList[1].PictureAName);
    }
}
